<?php


namespace app\common\model;


use app\common\enum\MainEnum;
use app\common\service\WarmUpCache;
use app\common\service\Redis;

class MapModel extends CommonModel
{
    protected $name = 'map';

    public static function onAfterUpdate()
    {
        return WarmUpCache::mapList();
    }

    public function getMapList()
    {
        return $this->with([])->order([
            'create_time' => 'desc',
        ])->select();
    }

    public static function getRedisMapList(): array
    {
        $data = (array)Redis::tableGet('mapList');
        if (!$data) {
            $data = self::onAfterUpdate();
        }
        return $data;
    }
}